library(pracma)

Diagonalization of Symmetric Matrices

A symmetric matrix is a matrix A such that t(A) = A. Such a matrix is necessarily square. ts main diagonal entries are arbitraty, but its other entries occur in pairs - on opposite sides of the main diagonal.

Example 1

a_symmetric_matrix <- matrix(c(0, -1, 0, -1, 5, 8, 0, 8, -7), nrow = 3, byrow = TRUE)

a_nonsymmetric <- matrix(c(1, -4, 0, -6, 1, -4, 0, -6, 1), nrow = 3, byrow = TRUE)

t(a_symmetric_matrix)==a_symmetric_matrix
##      [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE
t(a_nonsymmetric)==a_nonsymmetric
##       [,1]  [,2]  [,3]
## [1,]  TRUE FALSE  TRUE
## [2,] FALSE  TRUE FALSE
## [3,]  TRUE FALSE  TRUE

Example 2

Review of diagonalization of matrix.

Produce a Basis for each eigenspace.

A <- matrix(c(6, -2, -1, -2, 6, -1, -1, -1, 5), nrow = 3, byrow = TRUE)
A_info <- eigen(A)
# Let P be
P <- A_info$vectors
P
##               [,1]       [,2]       [,3]
## [1,]  7.071068e-01 -0.4082483 -0.5773503
## [2,] -7.071068e-01 -0.4082483 -0.5773503
## [3,] -1.947963e-17  0.8164966 -0.5773503
# Show Eigenvalues
A_info$values
## [1] 8 6 3
# Let D be
D <- matrix(c(8, 0, 0, 0, 6, 0, 0, 0, 3), nrow = 3, byrow = TRUE)
D
##      [,1] [,2] [,3]
## [1,]    8    0    0
## [2,]    0    6    0
## [3,]    0    0    3

A
##      [,1] [,2] [,3]
## [1,]    6   -2   -1
## [2,]   -2    6   -1
## [3,]   -1   -1    5
P%*%D%*%solve(P)
##      [,1] [,2] [,3]
## [1,]    6   -2   -1
## [2,]   -2    6   -1
## [3,]   -1   -1    5
P%*%D%*%t(P)
##      [,1] [,2] [,3]
## [1,]    6   -2   -1
## [2,]   -2    6   -1
## [3,]   -1   -1    5

Theorem 1:

If A is symmetric, then any two eigenvectors from different eigenspaces are orthogonal.

Theorem 2:

An nXn matrix A is orthogonally diagonalizable if and only if A is a symmetric matrix.

Example 3:

Orthogonally diagonalize the matrix A, where A is equal to

A <- matrix(c(3, -2, 4, -2, 6, 2, 4, 2, 3), nrow = 3, byrow = TRUE)
A
##      [,1] [,2] [,3]
## [1,]    3   -2    4
## [2,]   -2    6    2
## [3,]    4    2    3

whose characteristic equation is -(x-7)^2*(x+2)

A_info <- eigen(A)
A_info$values
## [1]  7  7 -2

Then, normalize the vectors.

P <- matrix(c(1/sqrt(2),-1/sqrt(18), -2/3, 0, 4/sqrt(18), -1/3, 1/sqrt(2), 1/sqrt(18), 2/3), nrow = 3, byrow = TRUE)
P
##           [,1]       [,2]       [,3]
## [1,] 0.7071068 -0.2357023 -0.6666667
## [2,] 0.0000000  0.9428090 -0.3333333
## [3,] 0.7071068  0.2357023  0.6666667
D <- matrix(c(7, 0, 0, 0, 7, 0, 0, 0, -2), nrow = 3, byrow = TRUE)

Theorem 3: The Spectral Theorem for Symmetric Matrices

An nXn symmetric matrix A has the following properties:

  1. A has n real eigenvalues, counting multiplicities.
  2. The dimension of the eigenspace for each eigenvalue lambda equals the multiplicity of lambda as a root of the characteristic equation.
  3. The eigenspaces are mutually orthogonal, in the sense that eigenvectors corresponging to different eigenvalues are orthogonal.
  4. A is orthogonally diagonalizable.

Here are a few exercices corresponding to the information above.

n

Quadratic Forms

Useful in economics as utility functions and in statistics as confidence ellipsoids.

A quadratic form on Rn is a function Q defined on Rn whose vlue at a vector x in Rn can be computed by and expression of the form Q(x) = t(x)%%I%%x = ||x||^2.. Examples 1 and show the connection between any symmetric matrix A and the quadratic form t(x)%%A%%x.

A <- matrix(c(1,-1,-2,2,2,-2), nrow = 3, byrow = TRUE)
svd(A)
## $d
## [1] 4.242641 0.000000
## 
## $u
##            [,1]      [,2]
## [1,] -0.3333333 0.6666667
## [2,]  0.6666667 0.6666667
## [3,] -0.6666667 0.3333333
## 
## $v
##            [,1]      [,2]
## [1,] -0.7071068 0.7071068
## [2,]  0.7071068 0.7071068